<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <div id="app">
        <p>选择你喜欢的专栏</p>
        <label v-for="(item, index) in list" :key="index">
            <input type="checkbox" name="hobby" :value="item" v-model="liList"> {{ item }}
        </label>
        <ul>
            <li v-for="(item, index) in liList" :key="index">{{ item }}</li>
        </ul>
    </div>

    <script src="../js/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                // 数据在这里
                list: ["科幻", "喜剧", "动漫", "冒险", "科技", "军事", "娱乐", "奇闻"],
                liList: []
            },
            // methods: {
            //     fn(item) {
            //         const index = this.liList.findIndex(v => v === item)
            //         if (index > -1) {
            //             this.liList.splice(index, 1)
            //         }
            //         else {
            //             this.liList.push(item)
            //         }
            //     }
            // }
        })
    </script>

</body>

</html>